﻿using GuanYijia.Application.OutPut;
using GuanYijia.DoMain;
using GuanYijia.DoMain.PageDto;
using GuanYijia.DoMain.RBAC;

using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Options;
using System;

namespace GuanYijia.EntityFarmeworkCore
{
    public class GuanYiJiaDbContext:DbContext
    {
        public GuanYiJiaDbContext(DbContextOptions<GuanYiJiaDbContext> options) : base(options) { }

       
        public DbSet<Account> Account { get; set; }
        public DbSet<CustomLog> CustomLogs { get; set; }
        public DbSet<Depot_Item> Depot_Items { get; set; }
        public DbSet<Documents> Documentss { get; set; }
        public DbSet<MaterialCategory> MaterialCategorys { get; set; }
        public DbSet<MaterialProperty> MaterialProperty { get; set; }
        public DbSet<Product_Attribute> Product_Attributes { get; set; }
        public DbSet<Product_Current_Stock> Product_Current_Stocks { get; set; }
        public DbSet<Product_Initial_Stock> Product_Initial_Stocks { get; set; }
        public DbSet<Product_Price> Product_Prices { get; set; }
        public DbSet<ProductInfo> ProductInfos { get; set; }
        public DbSet<Requisition> Requisitions { get; set; }
        public DbSet<Role> Roles { get; set; }
        public DbSet<Sales_Orders> Sales_Orderss { get; set; }
        public DbSet<Supplier> Suppliers { get; set; }
      
        public DbSet<User> Users { get; set; }
        public DbSet<UserBusiness> UserBusinesss { get; set; }
        public DbSet<Sales> Saless { get; set; }
        public DbSet<Creator> Creators { get; set; }
        public DbSet<Permissions> Permissionses { get; set; }
        public DbSet<RolePermissions> RolePermissionses { get; set; }
        public DbSet<Tenant> Tenants { get; set; }
        public DbSet<Hands_person> Hands_persons { get; set; }
        public DbSet<Head> Heads { get; set; }
        public DbSet<Warehouse> Warehouses { get; set; }
        public DbSet<PurchaseOrder> PurchaseOrders { get; set; }
        public DbSet<Customer> Customers { get; set; }
        public DbSet<Other_Warehousing_Head> Other_Warehousing_Heads { get; set; }
        public DbSet<Other_Warehousing_Item> Other_Warehousing_Items { get; set; }
        public DbSet<MaterialNeedModel> MaterialNeedModels { get; set; }
        public DbSet<ProductionTaskHead> ProductionTaskHeads { get; set; }
        public DbSet<ProductionTaskItem> ProductionTaskItems { get; set; }





        //-----------------记得注释-------------------------------
        public DbSet<ProductListDto> productListDtos { get; set; }
        public DbSet<ProductUpdateInfoDto> productUpdateInfoDto { get; set; }
        //---------------------------------------------------------
        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
           
            modelBuilder.Entity<Requisition>().HasQueryFilter(p => !p.IsDel);
            modelBuilder.Entity<PurchaseOrder>().HasQueryFilter(p => !p.IsDel);
            modelBuilder.Entity<Warehouse>().HasQueryFilter(p => !p.delete_Flag);
            modelBuilder.Entity<Supplier>().HasQueryFilter(p => !Convert.ToBoolean(p.delete_flag));
           // modelBuilder.Entity<Customer>().HasQueryFilter(p => !Convert.ToBoolean(p.delete_flag));
          
        }
        //这段代码的整体目的是在配置 DbContext 时，启用日志记录功能，使得所有的数据库操作信息都能通过控制台输出，便于开发和调试。使用这种方式可以帮助开发者更好地了解 Entity Framework Core 如何与数据库交互，特别是在调试时非常有用。
        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            base.OnConfiguring(optionsBuilder);
        optionsBuilder.LogTo(action: Console.WriteLine);
        }
       
    }
}